<template>
  <div ref="radar" class="radar" />
</template>

<script>
import * as echarts from 'echarts/core'
import { TitleComponent, LegendComponent } from 'echarts/components'
import { RadarChart } from 'echarts/charts'
import { CanvasRenderer } from 'echarts/renderers'

echarts.use([TitleComponent, LegendComponent, RadarChart, CanvasRenderer])
export default {
  name: 'Radar',
  mounted() {
    // 基于准备好的dom（具备一定的宽高），初始化echarts实例
    var myChart = echarts.init(this.$refs.radar)
    // 绘制图表
    myChart.setOption({
      title: {
        text: '个人情况概览'
      },
      legend: {
        data: ['个人水平', '平均水平'],
        right: '0',
        orient: 'vertical'
      },
      radar: {
        // shape: 'circle',
        indicator: [
          { name: '工作效率', max: 100 },
          { name: '考勤', max: 100 },
          { name: '积极性', max: 100 },
          { name: '帮助同事', max: 100 },
          { name: '自主学习', max: 100 },
          { name: '正确率', max: 100 }
        ]
      },
      series: [
        {
          name: '个人水平 vs 平均水平',
          type: 'radar',
          data: [
            {
              value: [100, 100, 100, 100, 100, 100],
              name: '个人水平'
            },
            {
              value: [80, 70, 60, 90, 100, 79],
              name: '平均水平'
            }
          ]
        }
      ]
    })
  }
}
</script>

<style lang="scss" scoped>
.radar {
  width: 500px;
  height: 400px;
}
</style>
